
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>分配详情</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta name="viewport" content="width=device-width, user-scalable=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta name=”apple-mobile-web-app-status-bar-style” content=”default” />
	<meta name=”apple-mobile-web-app-status-bar-style” content=”black” />
	<meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent” />
	<meta content="telephone=no" name="format-detection">
	<meta content="email=no" name="format-detection">
	<meta name="format-detection" content="telephone=no"/>
	<link rel="stylesheet" href="/mobile/css/weui.min.css" />
	<link rel="stylesheet" href="/mobile/css/jquery-weui.css" />
	<link rel="stylesheet" href="/mobile/css/wbNew.css" />
	<link href="/mobile/css/weChat.css" rel="stylesheet" />
	<script type="text/javascript" src="/mobile/js/fontSize.js"></script>
	<script type="text/javascript" src="/mobile/js/jquery-2.1.4.min.js"></script>
	<script src="/mobile/js/jquery-weui.js"></script>
	<script type="text/javascript" src="/mobile/js/common.js"></script>
	<script type="text/javascript" src="/mobile/js/ajaxfileupload.js"></script>
</head>
<body style="position:relative;">
<div class="main-content75 wb-service-bg1" id="service-records">
	<div class="main-nei-ctn">
		<div class="prebtn-icon" onclick="history.back()"><i class="cyfont">&#xe6d5;</i>上一页</div>
		<div class="main-nei-block">
			<div class="main-nei-tit"><span>基本信息</span></div>
			<div class="service-records-list">
				<#if wbRepair.repairType=="1">
					<div class="div-line-input">
						<label>设备名称：</label>
						<input readonly="readonly" type="text" value="${wbRepair.deviceName}">
					</div>
					<div class="div-line-input">
						<label>报修人：</label>
						<input readonly="readonly" type="text" value="${wbRepairUser.name!'无'}">
					</div>
					<div class="div-line-input">
						<label>联系方式：</label>
						<input readonly="readonly" type="text" value="${wbRepairUser.phone!'无'}">
					</div>
				</#if>
				<#if wbRepair.repairType=="2">
					<div class="div-line-input">
						<label>设备名称：</label>
						<input readonly="readonly" type="text" value="${wbDevices.name!'无'}">
					</div>
					<div class="div-line-input">
						<label>设备编号：</label>
						<input readonly="readonly" type="text" value="${wbDevices.num!'无'}">
					</div>
					<div class="div-line-input">
						<label>设备型号：</label>
						<input readonly="readonly" type="text" value="${wbDevices.deviceModel!'无'}">
					</div>
					<div class="div-line-input">
						<label>报修位置：</label>
						<input readonly="readonly" type="text" value="${wbDevices.roomName!'无'}">
					</div>

					<div class="div-line-input">
						<label>服务商名称：</label>
						<input readonly="readonly" type="text" value="${wbDevices.servicerName!'无'}">
					</div>
					<div class="div-line-input">
						<label>服务商电话：</label>
						<input readonly="readonly" type="text" value="${wbDevices.servicerMobile!'无'}">
					</div>
					<div class="div-line-input">
						<label>报修人：</label>
						<input readonly="readonly" type="text" value="${wbRepairUser.name!'无'}">
					</div>
					<div class="div-line-input">
						<label>联系方式：</label>
						<input readonly="readonly" type="text" value="${wbRepairUser.phone!'无'}">
					</div>
				</#if>
				<#if wbRepair.repairType=="3">
					<div class="div-line-input">
						<label>房间号：</label>
						<input readonly="readonly" type="text" value="${wxWbRoom.roomNum!'无'}">
					</div>
					<div class="div-line-input">
						<label>房间名称：</label>
						<input readonly="readonly" type="text" value="${wxWbRoom.roomName!'无'}">
					</div>
					<div class="div-line-input">
						<label>设备名称：</label>
						<input readonly="readonly" type="text" value="${wbRepair.deviceName}">
					</div>
					<div class="div-line-input">
						<label>报修人：</label>
						<input readonly="readonly" type="text" value="${wbRepairUser.name!'无'}">
					</div>
					<div class="div-line-input">
						<label>联系方式：</label>
						<input readonly="readonly" type="text" value="${wbRepairUser.phone!'无'}">
					</div>
				</#if>

				<div class="div-line-textarea border20">
					<label>故障描述：</label>
					<textarea readonly>${wbRepair.description}</textarea>
				</div>
				<!-- 图片上传 -->
				<div class="weui-cell border20" style="padding:0.2rem 0.25rem;border-bottom:none;">
					<div class="weui-cell__bd">
						<div class="weui-uploader">
							<div class="weui-uploader__hd">
								<p class="weui-uploader__title">图片上传：</p>
							</div>
							<div class="weui-uploader__hd">
								<ul class="weui-uploader__files" id="showCLJG" data-objectId="">

								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="main-nei-block">
			<div class="main-nei-tit"><span>维修记录</span></div>
			<div class="serviceRecord-ctn">
				<#if wbRepairRecordList?? && (wbRepairRecordList?size gt 0) >
				<#list wbRepairRecordList as wbRepairRecord>
					<div class="div-serviceRecord-line" onclick="showRecord(this)" data-status="${wbRepairRecord.status}" data-equipRecord="${wbRepairRecord.equipRecord}"  data-errorRecord="${wbRepairRecord.errorRecord}"  data-repairResult="${wbRepairRecord.repairResult}"  data-images="${wbRepairRecord.images}" data-repaimanName="${wbRepairRecord.repaimanName}" data-repaimanPhone="${wbRepairRecord.repaimanPhone}" >
						<div class="div-serviceRecord-txt ellipsis">${wbRepairRecord.repaimanName}进行了维修</div>
						<div class="div-serviceRecord-time">${wbRepairRecord.createTime?string('yyyy-MM-dd')}<i class="cyfont">&#xe60e;</i></div>
						<div class="div-circle"></div>
					</div>
				</#list>

					<#else>
						<div class="block-nodata">
							<span class="cyfont">&#xe869;</span>
							<h1>暂无维修记录</h1>
						</div>
				</#if>
				<#if wbRepair.status=="2">
					<div class="div-serviceRecord-line" style="height:1.2rem;">
						<div id="add" class="div-serviceRecord-add menu-bg-color open-popup" data-target="#full"><i class="cyfont">&#xe6ab;</i>添加维修记录</div>
						<div class="div-bigcircle"></div>
					</div>
				</#if>

			</div>
		</div>
		<#if wbRepair.status=="1">
		<div class="main-nei-block" style=" padding-bottom:0.4rem;">
			<div class="main-nei-tit"><span>服务商信息</span></div>
			<div class="service-records-list">
				<div class="service-records-list">
					<#if wbRepair.repairType=="1" || wbRepair.repairType=="3">
						<div class="div-line-input">
							<label>服务商：</label>
							<input type="text" id="servicerName" value="" placeholder="请选择服务商"/>
							<input type="hidden" id="servicerId" value="" placeholder="请选择服务商"/>
						</div>
					</#if>
					<div class="div-line-input">
						<label>维修人：</label>
						<input type="text" id="repairmanName" value="" placeholder="请选择维修人"/>
						<input type="hidden" id="repairmanId" value="" />
					</div>
				</div>

			</div>
			<div id="fpSubmit" class="foot-menu-btn mart40" style="width:45%">确认分配</div>
		</div>
		</#if>
	</div>
</div>
<!--待维修-->
<div id="full" class='weui-popup__container'>
	<div class="popup-repair-tit wb-service-bg1">
		维修详情<div class="closebtn close-popup"><i class="cyfont">&#xe623;</i></div>
	</div>
	<div class="weui-popup__overlay"></div>
	<div class="weui-popup__modal main-nei-ctn" style="width:100%;border-radius:0;padding:0;">
		<div class="main-nei-block" style="padding-bottom:0.54rem;border-radius:0;margin-bottom:0;padding-top:0;">
			<div class="service-records-list" style="margin-top:1rem; border-radius:0;display: none;" id="addRepair">
			<div class="div-line-textarea">
				<label>条件更换记录：</label>
				<textarea id="equipRecord" placeholder="请输入条件更换记录"></textarea>
			</div>
			<div class="div-line-textarea border20">
				<label>故障报告：</label>
				<textarea id="errorRecord" placeholder="请输入故障报告"></textarea>
			</div>
			<div class="div-line-textarea border20">
				<label>维修结果：</label>
				<textarea id="repairResult" placeholder="请输入条件更换记录"></textarea>
			</div>

			<!-- 图片上传 -->
			<div class="weui-cell border20" style="padding:0.2rem 0.25rem;border-bottom:none;">
				<div class="weui-cell__bd">
					<div class="weui-uploader">
						<div class="weui-uploader__hd"><p class="weui-uploader__title">图片上传：</p></div>
						<div class="weui-uploader__bd">
							<ul class="weui-uploader__files" id="wxPicResult" data-objectId="">

							</ul>
							<div class="weui-uploader__input-box pic-add" style="margin-top: 0.12rem;">
								<input id="fileWxjl"  name="file" onchange="cytImgUpload('fileWxjl','work/wb/repairRecord','wxPicResult','${token}')"  class="weui-uploader__input" type="file" accept="image/*" multiple>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 图片上传结束 -->

				<div class="div-menu-line mart40">
					<button type="button" onclick="wxjlSubmit(1)" class="wb-blue">成功</button>
					<button type="button" onclick="wxjlSubmit(2)" class="wb-green">返修</button>
				</div>
<!--			<div onclick="wxjlSubmit(1)" class="foot-menu-btn mart20 marb40">成功</div>-->
<!--			<div onclick="wxjlSubmit(2)"  class="foot-menu-btn mart20 marb40">返修</div>-->
<!--			-->
		</div>
		</div>
	</div>
</div>

<!--维修记录查看-->
<div id="recordShow" class='weui-popup__container'>
	<div class="popup-repair-tit wb-service-bg1">
		维修详情<div class="closebtn close-popup"><i class="cyfont">&#xe623;</i></div>
	</div>
	<div class="weui-popup__overlay"></div>
	<div class="weui-popup__modal main-nei-ctn" style="width:100%;border-radius:0;padding:0;">
		<div class="main-nei-block" style="padding-bottom:0.54rem;border-radius:0;margin-bottom:0;padding-top:0;">
			<div class="service-records-list" style="margin-top:1rem; border-radius:0;">
			<div class="div-line-input">
				<label>维修人：</label>
				<input type="text" id="repaimanNameShow" readonly value=""/>
			</div>
			<div class="div-line-input">
				<label>联系电话：</label>
				<input type="text" id="repaimanPhoneShow" readonly value=""/>
			</div>
			<div class="div-line-input">
				<label>结果状态：</label>
				<input type="text" id="recordStatus" readonly value=""/>
			</div>
			<div class="div-line-textarea">
				<label>条件更换记录：</label>
				<textarea id="equipRecordShow" readonly placeholder="请输入条件更换记录"></textarea>
			</div>
			<div class="div-line-textarea border20">
				<label>故障报告：</label>
				<textarea id="errorRecordShow" readonly placeholder="请输入故障报告"></textarea>
			</div>
			<div class="div-line-textarea border20">
				<label>维修结果：</label>
				<textarea id="repairResultShow" readonly placeholder="请输入条件更换记录"></textarea>
			</div>

			<!-- 图片上传 -->
			<div class="weui-cell border20" style="padding:0.2rem 0.25rem;border-bottom:none;">
				<div class="weui-cell__bd">
					<div class="weui-uploader">
						<div class="weui-uploader__hd"><p class="weui-uploader__title">图片上传：</p></div>
						<div class="weui-uploader__bd">
							<ul class="weui-uploader__files" id="wxPicResultShow" data-objectId="">

							</ul>

						</div>
					</div>
				</div>
			</div>

		</div>
		</div>
	</div>
</div>

<#if wbRepair.status=="2">
	<div class="bot-menu-xf-ctn wb-service-bg1">
		<div onclick="wcqdSubmit()"  class="bot-menu-xf">维修完成</div>
	</div>
</#if>

</body>

<script>
    var token = '${token}';
    var servicerJlId='${wbRepair.servicerId}';

    var applyId = '${applyId}';
    var repairId='${wbRepair.id}';
    var repairType='${wbRepair.repairType}';

	$(document).ready(function () {
        cytShowPic('${wbRepair.images}','showCLJG');
        if(repairType=="2" && servicerJlId!=null){
            changeUser(servicerJlId);
        }
        //选择服务商
        $("#servicerName").select({
            title: "选择服务商",
            items:${servicerCode},
            onChange: function(data){
            },
            onClose: function (d) {
                var titles = d.data.titles;
                var values = d.data.values;
                $("#servicerName").val(titles);
                $("#servicerId").val(values);
                $("#repairmanName").val("");
                $("#repairmanId").val("");
                changeUser(values);
            }

        });
        //选择维修人
        function changeUser(servicerId) {
            if(servicerId==null||servicerId==""){
                $.alert("请先选择服务商！");
                return false;
            }
            $.fn.doPost('/phone/wb/repairUser', {applyId:applyId,servicerId:servicerId}, function (result) {
                if (result.code == 0){
                    if(result.data!=null&&result.data.length>0){
                        $("#repairmanName").select("update", {
                            title: "选择维修人",
                            items:result.data,
                            onClose: function (d) {
                                var titles = d.data.titles;
                                var values = d.data.values;
                                $("#repairmanName").val(titles);
                                $("#repairmanId").val(values);
                            }
                        });
					}else{
                        $.toast("暂未设置维修人员","text");
					}

                }else {
                    $.toast(result.msg,"text");
                }
            });
        }
        // 待分配绑定
        $("#fpSubmit").on("click",function () {
            var repairmanId=$("#repairmanId").val();
            var servicerId=""
            if(repairType=="1"||repairType=="3"){
                servicerId= $("#servicerId").val();
                if (servicerId == null || servicerId == "") {
                    $.toast("请选择服务商","text");
                    return false;
                }
            }
            if (repairmanId == null || repairmanId == "") {
                $.toast("请选择维修人","text");
                return false;
            }
            $.fn.doPost('/phone/wb/assignMentRepair', {repairmanId:repairmanId,servicerId:servicerId,repairId:repairId}, function (result) {
                if (result.code == 0){
                    $.alert("分配成功","报修提示",function () {
                        window.location.href = "/phone/wb/my?token="+token+"&applyId="+applyId;
                    });
                }else {
                    $.toast(result.msg,"text");
                }
            });
        });
        //添加维修记录
        $("#add").bind("click",function () {
            $("#addRepair").show();
            $("#wxwcSubmit").hide();

        });

    })
    // 维修记录添加
    function wxjlSubmit(status) {
        var equipRecord=$("#equipRecord").val();
        if (equipRecord == null || equipRecord == "") {
            $.toast("请输入条件更换记录","text");
            return false;
        }
        var errorRecord=$("#errorRecord").val();
        if (errorRecord == null || errorRecord == "") {
            $.toast("请输入故障报告","text");
            return false;
        }
        var repairResult=$("#repairResult").val();
        if (errorRecord == null || errorRecord == "") {
            $.toast("请输入条件更换记录","text");
            return false;
        }
        var images = $("#wxPicResult").attr("data-objectId");//附件id

        $.fn.doPost('/phone/wb/repairRecord', {applyId:applyId,servicerId:servicerJlId,repairId:repairId,status:status,
            equipRecord:equipRecord,errorRecord:errorRecord,
            repairResult:repairResult,images:images,repairmanId:"${wbUser.id}",repaimanName:"${wbUser.name}",repaimanPhone:"${wbUser.phone}"}, function (result) {
            if (result.code == 0){
                $.alert("提交成功","报修提示",function () {
                    if(status=="2"){
                        window.location.href = "/phone/wb/my?token="+token+"&applyId="+applyId;
                    }else{
                        window.location.reload();
                    }

                });
            }else {
                $.toast(result.msg,"text");
            }
        });
    }
    // 维修记录完成确认
    function wcqdSubmit() {

        $.fn.doPost('/phone/wb/repairStatus',{repairId:repairId,status:"4"}, function (result) {
            if (result.code == 0){
                $.alert("提交成功","报修提示",function () {
                    window.location.href = "/phone/wb/my?token="+token+"&applyId="+applyId;
                });
            }else {
                $.toast(result.msg,"text");
            }
        });
    }
    // 维修记录查看
    function showRecord(obj) {
	    //维修结果:1、处理成功，2、返修
	    var status=$(obj).attr("data-status");
	    if(status=="1"){
            $("#recordStatus").val("处理成功");
		}else{
            $("#recordStatus").val("返修");
		}
        $("#repaimanNameShow").val($(obj).attr("data-repaimanName"));
        $("#repaimanPhoneShow").val($(obj).attr("data-repaimanPhone"));
        $("#equipRecordShow").html($(obj).attr("data-equipRecord"));
        $("#errorRecordShow").html($(obj).attr("data-errorRecord"));
        $("#repairResultShow").html($(obj).attr("data-repairResult"));
        var images=$(obj).attr("data-images");
        $("#wxPicResultShow").html("");
        if(images!=null&&images!=""){
            cytShowPic($(obj).attr("data-images"),'wxPicResultShow');
		}

        $("#recordShow").popup();
    }
</script>
</html>
